// ./src/routes/Users.jsx
import React, { Component, PropTypes } from 'react';
import { connect } from 'dva';
import {menu, Table, message, Popconfirm } from 'antd'

import UserList from '../../../components/system/organization/user/UserList';
import UserSearch from '../../../components/system/organization/user/UserSearch';
import UserModal from '../../../components/system/organization/user/UserModal';
import users from '../../../models/system/organization/users'


import styles from './user.less';

function user({ location, dispatch, users }) {

  const {
    visible,loading, list, total, current,
    currentItem, modalVisible, modalType
    } = users;



  const userSearchProps = {
    userSelect(date){
      dispatch({
        type: 'users/query',
        payload: date
      });

    }
  };
  const userListProps = {
	dataSource: list,
		total,
		loading,
		current,
     addUser(){
        dispatch({
          type:'users/ModalOpen',
           payload: {}
        });

    }
	  };
  const userModalProps = {
     visible,
     dispatch,

  };

  return (
    <div className={styles.normal}>
    <div className={styles.title}>当前位置：用户管理</div>

      <UserSearch {...userSearchProps}  />

      <UserList {...userListProps}


	  />

      <UserModal {...userModalProps} />


    </div>
  );
}

user.propTypes = {
  users: PropTypes.object,
};

// ָnamespace的 users
function mapStateToProps({ users }) {
  return {users};
}

// model与routes连接
export default connect(mapStateToProps)(user);
